#!/usr/bin/env bash
base_path=~/docker/loki/grafna
script_pwd=$(dirname "$0")
container_name=loki-grafana

rm -rf $base_path/config 
mkdir -p $base_path/{config,data,logs,plugins}
cp -r $script_pwd/datasources.yaml $base_path/config/.
cp -r $script_pwd/grafana.ini $base_path/config/.

docker rm -f $container_name

docker network create loki

docker run -d \
--name $container_name \
--network loki \
-v $base_path/config/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yml \
-v $base_path/config/grafana.ini:/etc/grafana/grafana.ini \
-v $base_path/data:/var/lib/grafana \
-v $base_path/logs:/var/log/grafana \
-v $base_path/plugins:/var/lib/grafana/plugins \
-p 3000:3000 \
grafana/grafana:9.5.21